<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		  <#assign base=request.contextPath  />
		 <link rel="stylesheet" href="${base}/js/layui/css/layui.css?t=1534970980648" media="all">
		 <script type="text/javascript" src="${base}/js/zhang.js"></script>
		 <script src="${base}/js/layui/layui.js" charset="utf-8"></script>
         <script type="text/javascript" src="${base}/js/ztree/jquery-1.4.4.min.js"></script>
         <script src="${base}/js/jquery.min.js"></script>

		<style type="text/css">
		form{
		  padding:20px;
		}
		.layui-btn-radius{
        			border-radius: 5px;
        		}
		</style>
	</head>
	<body>

	<form class="layui-form" action="">
        <div class="layui-form-item">
            <div class="layui-inline">
                 <label class="layui-form-label"><a style="color:red">*</a>&nbsp;姓名</label>
                       <div class="layui-input-inline">
                            <input name="number" id="sname" lay-verify="required" autocomplete="off" class="layui-input isNull" type="text">
                        </div>
                      </div>

                       <div class="layui-inline">
                            <label class="layui-form-label"><a style="color:red">*</a>&nbsp;日期</label>
                                   <div class="layui-input-inline">
                                         <input name="date" id="date" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input isNull" type="text">
                                   </div>
                       </div>



                 <div class="layui-inline">
                       <label class="layui-form-label"><a style="color:red">*</a>&nbsp;套餐项</label>
                              <div class="layui-input-block">
                                     <select name="city" lay-verify="required" lay-search="" class=" isNull" id="mealName">
                                        <option value=""></option>
                                     </select>
                              </div>
                   </div><br/><br/>



    	      <div class="layui-inline">
                     <label class="layui-form-label" ><a style="color:red">*</a>&nbsp;拜访次数</label>
                              <div class="layui-input-inline">
                                      <input name="number" id="visit" lay-verify="required " autocomplete="off" class="layui-input isNull" type="text">
                               </div>
              </div>
               <div class="layui-inline">
                   <label class="layui-form-label" ><a style="color:red">*</a>&nbsp;跟进次数</label>
                       <div class="layui-input-inline">
                             <input name="number" id="follow" lay-verify="required "  autocomplete="off" class="layui-input isNull" type="text">
                       </div>
               </div>
             <div class="layui-inline">
                        <label class="layui-form-label" ><a style="color:red">*</a>&nbsp;后续消费</label>
                             <div class="layui-input-inline">
                                   <input name="number" id="consumption" lay-verify="required "  autocomplete="off" class="layui-input " type="text">
                              </div>
              </div>
            <div class="layui-inline">
                    <label class="layui-form-label" ><a style="color:red">*</a>&nbsp;是否转介绍</label>
                          <div class="layui-input-inline">
                                 <input name="number" id="whether" lay-verify="required"  autocomplete="off" class="layui-input isNull" type="text">
                        </div>
             </div>
            <div class="layui-inline">
                       <label class="layui-form-label" ><a style="color:red">*</a>&nbsp;录入人</label>
                                <div class="layui-input-inline">
                                      <input name="number" id="person" lay-verify="required"  autocomplete="off" class="layui-input isNull" type="text">
                               </div>
              </div>
             <div class="layui-inline">
                        <label class="layui-form-label" ><a style="color:red">*</a>&nbsp;部门</label>
                            <div class="layui-input-inline">
                               <input name="number" id="dept" lay-verify="required"  autocomplete="off" class="layui-input isNull" type="text">
                           </div>
              </div>



               <div class="layui-form-item">
                       <div class="layui-input-block">
                           <button class="layui-btn layui-btn-radius" lay-submit lay-filter="formDemo" type="button" onclick="onSubmit()" style="background-color: #0092EF;">立即提交</button>
                           <button type="reset" class="layui-btn layui-btn-primary layui-btn-radius">重置</button>
                     </div>
               </div>
            </div>
        </form>

<script>
layui.use(['form', 'layedit', 'laydate','layer'], function(){
  var form = layui.form
  ,layer = layui.layer
  ,layedit = layui.layedit
  ,laydate = layui.laydate;
   //日期
  laydate.render({
    elem: '#date'
  });

});
//添加
function onSubmit(){
var jsonData = {};
    //姓名
    jsonData.sname = $("#sname").val();
    //日期
    jsonData.date = $("#date").val();
    //套餐
    jsonData.meal = $("#mealName").val();
    //拜访次数
    jsonData.visit = $("#visit").val();
    //跟进次数
    jsonData.follow = $("#follow").val();
    //后续消费
    jsonData.consumption = $("#consumption").val();
    //是否转介绍
    jsonData.whether = $("#whether").val();
    //录入人
    jsonData.person = $("#person").val();
    //部门
    jsonData.dept = $("#dept").val();

    if(!isNull()){
        return;
       }
        //alert("进入ajax")
     $.ajax({
        type:"POST",
        url:"${base}/situationAnalysis/insertSituationAnalysis",
        data:{"param":JSON.stringify(jsonData)},
        success:function(data){

             layer.msg(data);
setTimeout(function(){
   var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
          parent.layer.close(index); //再执行关闭
},800)
                 //姓名
                 jsonData.sname = $("#sname").val("");
                 //日期
                 jsonData.date = $("#date").val("");
                 //套餐
                 jsonData.meal = $("#mealName").val("");
                 //拜访次数
                 jsonData.visit = $("#visit").val("");
                 //跟进次数
                 jsonData.follow = $("#follow").val("");
                 //后续消费
                 jsonData.consumption = $("#consumption").val("");
                 //是否转介绍
                 jsonData.whether = $("#whether").val("");
                 //录入人
                 jsonData.person = $("#person").val("");
                 //部门
                 jsonData.dept = $("#dept").val("");
                var table = parent.layui.table;
                //表刷新方法
                table.reload('testReload', {
                url: '${base}/situationAnalysis/selectSituationAnalysis'
                ,where: {} //设定异步数据接口的额外参数

            });
        }
     });

}
//获取添加时候的套餐项
var bas = "${base}"
var home_meal = getMealName(bas,"mealName")
for(var i=0;i<home_meal.length;i++){
$("#mealName").append(
    ' <option value="'+home_meal[i].id+'">'+home_meal[i].mealName+'</option>'
)
}

</script>
	</body>
</html>
